import axios from 'axios'

axios.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded';
axios.defaults.headers.get['Content-Type'] = 'application/x-www-form-urlencoded';
axios.defaults.transformRequest = [function (data) {
  let ret = ''
  for (let it in data) {
    ret += encodeURIComponent(it) + '=' + encodeURIComponent(data[it]) + '&'
  }
  return ret
}]

export function upload (data) {
  console.log(data)
  return axios({
      method: 'post',  // 方式一定是post
      url: 'http://192.168.232.137:5000/api/upload',
      timeout: 20000,
      data: data       // 参数需要是单一的formData形式
    })
}

